<?php
    class Tiri_Config{

        private static $_config;

        private function __construct(){

        }
        static public function getInstance(){
            if(NULL == self::$_instance){
                self::$_instance = new Tiri_Config();
            }
            return self::$_instance;
        }

        static public function loadConfig($config = array()){
            if(count($config) > 0){
                foreach($config as $key => $value){
                    self::$_config[$key] = $value;
                } 
            }
        }

        static public function get($key , $default = NULL){
            if(isset(self::$_config[$key])){
                return self::$_config[$key];
                /** 这里有一个默认机制，要在文档中标示出来 */
            }else if(isset(self::$_config['default_'.$key])){
                    return self::$_config['default_'.$key];
                }
                return $default;

        }
        static public function dump(){
            var_dump(self::$_config);
        }

    }
?>